package com.coder520.androidstudybroadcaster;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.coder520.androidstudybroadcaster.bean.User;

public class MainActivity extends Activity {
    static final String ACTION_BROADCAST_TEST =
            "com.coder520.androidstudybroadcaster.TEST";
    static final String EXTRA_USER = "extra_user";
    private UserBroadcastReceiver mReceiver;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        IntentFilter intentFilter = new IntentFilter(ACTION_BROADCAST_TEST);
        mReceiver = new UserBroadcastReceiver();
//        registerReceiver(mReceiver, intentFilter);
    }

    @Override
    protected void onStart() {
        super.onStart();
//        Intent inten = new Intent(MainActivity.this/*Context*/, MainActivity.class);
        Intent intent = new Intent(ACTION_BROADCAST_TEST);
        User user = new User("laowang", 50);
        intent.putExtra(EXTRA_USER, user);
//        startActivity();
//        startActivityForResult();
//        sendBroadcast(intent);
        sendOrderedBroadcast(intent, null/*permission*/);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        unregisterReceiver(mReceiver);
    }
}
